<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>两新党组织基本信息</title>
<link href="/djzx/css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/djzx/js/jquery-1.8.1.min.js"></script>
<script language="javascript" src="/djzx/js/backPage/clientSideApp.js"></script>
<script language="JavaScript" type="text/javascript" src="/djzx/js/backPage/win_center.js"></script>
<script type="text/javascript" src="/djzx/js/layer/layer.js" ></script>
<SCRIPT language=JavaScript type=text/JavaScript>
//查询模式：0代表查询，1代表高级查询
var queryMode = 0;

var name_layer = "";
var address_layer = "";
var type_layer = "";
var workerNum_layer = "";
var leaderName_layer = "";
var leaderTitle_layer = "";
var leaderTel_layer = "";
var contacts_layer = "";
var contactsTel_layer = "";
var fax_layer = "";
var zip_layer = "";

window.onload = function(){
	var flag = $('#flag').val();
	if(flag != ""){
		alert(flag);
	}
	$('#flag').val('');
};

function delParty(timeKey){
	var r = confirm("确定要删除吗?");
	if(r){
		$.post(
				"/djzx/LXPartyAction!delPartyInfo.action",
				{
					"lxParty.timeKey":timeKey
				},
				function(data){
					alert(data.message);
					if(data.success){
						location.href="/djzx/LXPartyAction!getPartyInfoListForPage.action";
					}
				},
				"json"
				)
	}
}

function toAddParty(){
	window.location.href="/djzx/backPage/liangxin/addPartyInfo.jsp";
}

function toEditParty(timeKey){
	window.location.href="/djzx/LXPartyAction!toEditPartyInfo.action?lxParty.timeKey=" + timeKey;
}

function searchParty(){
	queryMode = 0;
	ajaxParty(1);
}

function firstPage(){
	ajaxParty(1);
}

function prevPage(){
	var start =parseInt($("#start").html());
	if(start <= 1){
		start = 1;
	}else{
		start--;
	}
	ajaxParty(start);
}

function nextPage(){
	var start =parseInt($("#start").html());
	var count = parseInt($("#pageCount").html());
	if(start >= count){
		start = count;
	}else{
		start++;
	}
	ajaxParty(start);
}

function endPage(){
	var last = parseInt($("#pageCount").html());
	ajaxParty(last);
}

function ajaxParty(start){
	var name = "";
	var address = "";
	var type = "";
	var workerNum = "";
	var leaderName = "";
	var leaderTitle = "";
	var leaderTel = "";
	var contacts = "";
	var contactsTel = "";
	var fax = "";
	var zip = "";
	
	if(queryMode == 0){ // 查询
		var param = $.trim($('#param').val());
		var paramValue = $.trim($('#paramValue').val());
		
		if(param == 'name'){
			name = paramValue;
		}else if(param == 'address'){
			address = paramValue;
		}else if(param == 'type'){
			type = paramValue;
		}else if(param == 'workerNum'){
			if(isNaN(paramValue) || paramValue == ''){
				alert("请输入数字！");
				return false;
			}
			workerNum = parseInt(paramValue);
		}else if(param == 'leaderName'){
			leaderName = paramValue;
		}else if(param == 'leaderTitle'){
			leaderTitle = paramValue;
		}else if(param == 'leaderTel'){
			leaderTel = paramValue;
		}else if(param == 'contacts'){
			contacts = paramValue;
		}else if(param == 'contactsTel'){
			contactsTel = paramValue;
		}else if(param == 'fax'){
			fax = paramValue;
		}else if(param == 'zip'){
			zip = paramValue;
		}
	}else if(queryMode == 1){ // 高级查询
		name = name_layer;
		address = address_layer;
		type = type_layer;
		workerNum = workerNum_layer;
		leaderName = leaderName_layer;
		leaderTitle = leaderTitle_layer;
		leaderTel = leaderTel_layer;
		contacts = contacts_layer;
		contactsTel = contactsTel_layer;
		fax = fax_layer;
		zip = zip_layer;
	} 	
	
	$.ajax({
		url:'${pageContext.request.contextPath}/LXPartyAction!searchPartyList.action',
		data:{
			"page.currPage":start,
			"lxParty.name":name,
			"lxParty.address":address,
			"lxParty.type":type,
			"lxParty.workerNum":workerNum,
			"lxParty.leaderName":leaderName,
			"lxParty.leaderTitle":leaderTitle,
			"lxParty.leaderTel":leaderTel,
			"lxParty.contacts":contacts,
			"lxParty.contactsTel":contactsTel,
			"lxParty.fax":fax,
			"lxParty.zip":zip
		},
		type:'post',
		dataType:'json',
		success:function(data){
			var str="";
			if(data.map.length>0){
				$.each(data.map,function(i){
					str+='<tr><td class="td_01">'+data.map[i].index+
					'</td><td class="td_01"><a href="/djzx/LXPartyAction!toShowPartyInfo.action?lxParty.timeKey='+data.map[i].timeKey+'" target="_blank">'+data.map[i].name+'</a>'+
					'</td><td class="td_01">'+data.map[i].address+
					'</td><td class="td_01">'+data.map[i].type+
					'</td><td class="td_01">'+data.map[i].workerNum+
					'</td><td class="td_01">'+data.map[i].leaderName+
					'</td><td class="td_01">'+data.map[i].leaderTitle+
					'</td><td class="td_01">'+data.map[i].leaderTel+
					'</td><td class="td_01">'+data.map[i].contacts+
					'</td><td class="td_01">'+data.map[i].contactsTel+
					'</td><td class="td_01">'+data.map[i].fax+
					'</td><td class="td_01">'+data.map[i].zip+
					'</td><td nowrap class="td_01"><a href="/djzx/LXPartyAction!toShowPartyInfo.action?lxParty.timeKey='+data.map[i].timeKey+'" target="_blank">查看</a><a href="javascript:void(0)" onclick="toEditParty('+data.map[i].timeKey+')">编辑</a>|<a href="javascript:void(0)" onclick="delParty('+data.map[i].timeKey+')">删除</a></td></tr>';
				});
			}
			$("#nodeContent").html(str);
			$("#start").html(data.object.currPage);
			$("#pageCount").html(data.object.pageCount);
			$("#count").html(data.object.count);
		}
	}); 
}

function advancedQueryParty(){
	queryMode = 1;
	name_layer = $.trim($('#name').val());
	address_layer = $.trim($('#address').val());
	type_layer = $.trim($('#type').val());
	workerNum_layer = $.trim($('#workerNum').val());
	leaderName_layer = $.trim($('#leaderName').val());
	leaderTitle_layer = $.trim($('#leaderTitle').val());
	leaderTel_layer = $.trim($('#leaderTel').val());
	contacts_layer = $.trim($('#contacts').val());
	contactsTel_layer = $.trim($('#contactsTel').val());
	fax_layer = $.trim($('#fax').val());
	zip_layer = $.trim($('#zip').val());
	ajaxParty(1);
}

function tree(tag,imgTag){
	if($('#' + tag).css('display') == 'none'){
		$('#' + tag).show();
		$('#' + imgTag).attr('src','/djzx/images/minus.png');
	}else{
		$('#' + tag).hide();
		$('#' + imgTag).attr('src','/djzx/images/plus.png');
	}
}

function toMemberInfo(){
	window.location.href = "/djzx/LXMemberAction!getMemberInfoListForPage.action";
}

/* function importPartyList(){
	var excels = $("#excel");
	for(var i=0;i<excels.length;i++){
		var excel = excels[i];
		if($(excel).val().length==0){
			alert("上传Excel不能为空");
			return;
		}
	}
	
	$('#form1').submit();
} */

function toPartyActivity(partyName){
	window.location.href = "/djzx/LXPartyActivityAction!getPartyActivityListForPage.action?partyNameParam=" + encodeURI(encodeURI(partyName));
}

</SCRIPT>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- <form action="/djzx/LXPartyAction!importExcelToPartyList.action" method="post" id="form1" enctype="multipart/form-data">
<input type="file" id="excel" name="excel" />
</form> -->
<input id="flag" value="${flag }" type="hidden"/>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
      <tr>
        <td width="15"><img src="/djzx/images/index_32.gif" width="9" height="9"></td>
        <td valign="bottom" class="title">基本信息查询</td>
      </tr>
    </table></td>
  </tr>
</table>
<br>
<table width="95%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td class="td_page">
	   <%-- 查询参数：
      <select name="param" id="param">
      	<option value="name">党组织名称</option>
        <option value="address">地址</option>
        <option value="type">单位性质</option>
        <option value="workerNum">单位员工数</option>
        <option value="leaderName">单位负责人姓名</option>
        <option value="leaderTitle">负责人党内职务</option>
        <option value="leaderTel">负责人联系方式</option>
        <option value="contacts">联系人</option>
        <option value="contactsTel">联系人电话</option>
        <option value="fax">传真</option>
        <option value="zip">邮编</option>
      </select>
             参数值：
      <input name="paramValue" id="paramValue" type="text" class="input" size="10">
      <input type="button" class="buttonface02" value=" 查询 " onclick="searchParty()">
      <input type="button" class="buttonface02" value=" 高级查询 " id="advancedQuery"> --%>
      <s:if test="#session.role.adminPower == 1 || (#session.role.oneLevelPower == 1 && #session.role.oneLevelNO == '01')">
      <input type="button" class="buttonface02" value=" 两新所有党员信息" onclick="toMemberInfo()">
      </s:if>
      <s:else>
      <input type="button" class="buttonface02" style="visibility: hidden;">
      </s:else>
	  <!-- <input type="button" class="buttonface02" value=" 新增 " onclick="toAddParty()"> -->
	  <!-- <input type="button" class="buttonface02" value=" 导入党组织 " onclick="importPartyList()"> -->
    </td>
  </tr>
</table>
<br>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td nowrap class="td_top">序号</td>
    <td nowrap class="td_top">党组织名称</td>
    <td nowrap class="td_top">地址</td>
    <td nowrap class="td_top">单位性质</td>
    <td nowrap class="td_top">单位员工数</td>
    <td nowrap class="td_top">负责人姓名</td>
     <td nowrap class="td_top">负责人党内职务</td>
	 <td nowrap class="td_top">负责人电话</td>
	 <td nowrap class="td_top">联系人姓名</td>
     <td nowrap class="td_top">联系人电话</td>
	 <td nowrap class="td_top">传真</td>
	 <td nowrap class="td_top">邮编</td>
	 <td nowrap class="td_top">其他信息</td>
  </tr>
  <tbody id="nodeContent">
  <s:iterator value="lxGeneralPartyList" var="lxgp" status="statu1">
  <tr> 
    <td class="td_01">${statu1.index+1 }</td>
    <td class="td_01">
    	<img id="img_${statu1.index }" style="vertical-align: middle;" onClick="tree('child_${statu1.index }','img_${statu1.index }');" src="/djzx/images/plus.png" width="19" height="20">
    	<s:if test="#session.role.adminPower == 1 
    	|| (#session.role.oneLevelPower == 1 && #session.role.oneLevelNO == '01')
    	|| (#session.role.twoLevelPower == 1 && #session.role.twoLevelNO == #lxgp.timeKey)">
    	<a href="/djzx/LXPartyAction!toShowGeneralPartyInfo.action?lxGeneralParty.timeKey=${lxgp.timeKey}" target="_blank">${lxgp.name }</a>
    	</s:if>
    	<s:else>
    	${lxgp.name }
    	</s:else>
    </td>
    <td class="td_01">${lxgp.address }</td>
    <td class="td_01">${lxgp.type }</td>
    <td class="td_01">${lxgp.workerNum }</td>
    <td class="td_01">${lxgp.leaderName }</td>
    <td class="td_01">${lxgp.leaderTitle }</td>
	<td class="td_01">${lxgp.leaderTel }</td>
    <td class="td_01">${lxgp.contacts }</td>
    <td class="td_01">${lxgp.contactsTel }</td>
    <td class="td_01">${lxgp.fax }</td>
	<td class="td_01">${lxgp.zip }</td>
	<td class="td_01">
	<a href="javascript:void(0);" onclick="toPartyActivity('${lxgp.name }')">党建动态</a>
	</td>
  </tr>
  <tr>
  	<td colspan="13">
      <table id="child_${statu1.index }" style="display: none;" width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
		    <td nowrap class="td_form03">党组织名称</td>
		    <td nowrap class="td_form03">地址</td>
		    <td nowrap class="td_form03">单位性质</td>
		    <td nowrap class="td_form03">单位员工数</td>
		    <td nowrap class="td_form03">负责人姓名</td>
		     <td nowrap class="td_form03">负责人党内职务</td>
			 <td nowrap class="td_form03">负责人电话</td>
			 <td nowrap class="td_form03">联系人姓名</td>
		     <td nowrap class="td_form03">联系人电话</td>
			 <td nowrap class="td_form03">传真</td>
			 <td nowrap class="td_form03">邮编</td>
			 <td nowrap class="td_form03">操作</td>
			 <td nowrap class="td_form03">其他信息</td>
	    </tr>
        <s:iterator value="lxPartyList" var="lxp" status="statu2">
  		<s:if test="#lxp.lxGeneralParty.timeKey==#lxgp.timeKey">
        <tr>
	      <td class="td_form01">
	      	<s:if test="#session.role.adminPower == 1 
	    	|| (#session.role.oneLevelPower == 1 && #session.role.oneLevelNO == '01')
	    	|| (#session.role.twoLevelPower == 1 && #session.role.twoLevelNO == #lxgp.timeKey)">
	    	<a href="/djzx/LXPartyAction!toShowPartyInfo.action?lxParty.timeKey=${lxp.timeKey}" target="_blank">${lxp.name }</a>
	    	</s:if>
	    	<s:else>
	    	${lxp.name }
	    	</s:else>
	      </td>
	      <td class="td_form01">${lxp.address }</td>
	      <td class="td_form01">${lxp.type }</td>
	      <td class="td_form01">${lxp.workerNum }</td>
	      <td class="td_form01">${lxp.leaderName }</td>
	      <td class="td_form01">${lxp.leaderTitle }</td>
		  <td class="td_form01">${lxp.leaderTel }</td>
	      <td class="td_form01">${lxp.contacts }</td>
	      <td class="td_form01">${lxp.contactsTel }</td>
	      <td class="td_form01">${lxp.fax }</td>
		  <td class="td_form01">${lxp.zip }</td>
		  <td nowrap class="td_form01">
		  	<s:if test="#session.role.adminPower == 1 
	    	|| (#session.role.oneLevelPower == 1 && #session.role.oneLevelNO == '01')
	    	|| (#session.role.twoLevelPower == 1 && #session.role.twoLevelNO == #lxgp.timeKey)">
			<a href="/djzx/LXPartyAction!toShowPartyInfo.action?lxParty.timeKey=${lxp.timeKey}" target="_blank">查看</a>|
			<a href="#" onclick="toEditParty(${lxp.timeKey})">编辑</a>|
			<a href="#" onclick="delParty(${lxp.timeKey })">删除</a>
			</s:if>
		  </td>
		  <td class="td_form01">
		  <a href="javascript:void(0);" onclick="toPartyActivity('${lxp.name }')">党建动态</a>
		  </td>
	    </tr>
	    </s:if>
	    </s:iterator>
  	  </table>
  	</td>
  </tr>
  </s:iterator>
  <%-- <s:iterator value="lxPartyList" var="lx" status="statu">
  <tr> 
    <td class="td_01">${statu.index+1 }</td>
    <td class="td_01">
    	<a href="/djzx/LXPartyAction!toShowPartyInfo.action?lxParty.timeKey=${lx.timeKey}" target="_blank">${lx.name }</a>
    </td>
    <td class="td_01">${lx.address }</td>
    <td class="td_01">${lx.type }</td>
    <td class="td_01">${lx.workerNum }</td>
    <td class="td_01">${lx.leaderName }</td>
    <td class="td_01">${lx.leaderTitle }</td>
	<td class="td_01">${lx.leaderTel }</td>
    <td class="td_01">${lx.contacts }</td>
    <td class="td_01">${lx.contactsTel }</td>
    <td class="td_01">${lx.fax }</td>
	<td class="td_01">${lx.zip }</td>
	<td nowrap class="td_01">
		<a href="/djzx/LXPartyAction!toShowPartyInfo.action?lxParty.timeKey=${lx.timeKey}" target="_blank">查看</a>|
		<a href="#" onclick="toEditParty(${lx.timeKey})">编辑</a>|
		<a href="#" onclick="delParty(${lx.timeKey })">删除</a>
	</td>
  </tr>
  </s:iterator> --%>
  </tbody>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td nowrap width="95%" class="td_top"></td>
  </tr>
</table>
<table width="95%"  border="0" cellpadding="0" cellspacing="0" class="table02" align="center">
  <tr>
    <td height="30" align="right">
	    <img src="/djzx/images/1.gif" width="4" height="5" align="absmiddle"> <a href="javascipt:;" onclick="firstPage()">首页</a>　
	    <img src="/djzx/images/2.gif" width="3" height="5" align="absmiddle"> <a href="javascipt:;" onclick="prevPage()">上一页</a>　 
	    <img src="/djzx/images/2-2.gif" width="3" height="5" align="absmiddle"> <a href="javascipt:;" onclick="nextPage()">下一页</a>　 
	    <img src="/djzx/images/3.gif" width="4" height="5" align="absmiddle"> <a href="javascipt:;" onclick="endPage()">末页</a>　　
	         当前第<span id="start">${page.currPage}</span>页,共<span id="pageCount">${page.pageCount}</span>页,共<span id="count">${page.count}</span>条记录
    </td>
  </tr>
</table>
<script type="text/javascript">
$(document).ready(function(){
	var layerW = '800px';
	var layerH = '400px';
	   
	// 高级查询界面
	$('#advancedQuery').on('click', function(){ 
		var content = '<br><table align="center" width="95%" border="0" cellspacing="0" cellpadding="0">'
				+ '<tr><td width="120" height="24" class="td_form01">党组织名称</td>' 
				+ '<td nowrap class=td_form02><input type="text" size="30" id="name" /></td>'
				+ '<td width="120" class="td_form01">地址</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="address" /></td></tr>'
        		+ '<tr><td height="24" class="td_form01">单位性质</td>'
        		+ '<td nowrap class=td_form02><input type="text" size="30" id="type" /></td>'
        		+ '<td class="td_form01">单位员工数</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="workNum" /></td></tr>'
        		+ '<tr><td height="24" class="td_form01">单位负责人姓名</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="leaderName" /></td>'
      			+ '<td class="td_form01">负责人党内职务</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="leaderTitle" /></td></tr>'
      			+ '<tr><td class="td_form01">负责人联系方式</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="leaderTel" /></td>'
      			+ '<td class="td_form01">联系人</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="contacts" /></td></tr>'
      			+ '<tr><td class="td_form01">联系人电话</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="contactsTel" /></td>'
      			+ '<td class="td_form01">传真</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="fax" /></td></tr>'
      			+ '<tr><td class="td_form01">邮编</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="zip" /></td></tr></table>'
      			+ '<br><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">'
      			+ '<tr><td align="center"><input name="Submit2" type="submit" class="buttonface" value="  查询  " onClick="advancedQueryParty()"></td></tr></table>';
      			
		// 页面一打开就执行，放入ready是为了layer所需配件（css、扩展模块）加载完毕
		layer.ready(function(){ 
			//官网欢迎页
			layer.open({
				type: 1,
				//skin: 'layui-layer-lan',
				title: '高级查询',
				fix: false,
				shadeClose: true,
				maxmin: true,
				area: [layerW, layerH],
				content: content,
				end: function(){
					//layer.tips('试试相册模块？', '#photosDemo', {tips: 1})
				}
			});
		});
	});
});
</script>
</body>
</html>
